<template>
  <div id="main">
    <van-form @submit="sub">
      <van-field
        v-model="article.articleTitle"
        name="标题"
        label="标题"
        placeholder="请输入标题"
        :rules="[{ required: false, message: '' }]"
      />

        <mavon-editor  @imgAdd="addImage" ref="md" />

      <div style="margin: 16px;">
        <van-button round block type="info" native-type="submit">提交</van-button>
      </div>
    </van-form>


<!--    <button @click="sub">提交</button>-->
  </div>
</template>

<script>
    export default {
        name: "article",
        data(){
          return{
            article:{
              articleTitle:'',
              articleWriter:''
            }
          }
        },
      methods:{
        onSubmit() {

        },
        addImage:function (name,file) {
            console.log(name)
            console.log(file)
        },
        sub:function () {
          //获取到了html格式的所有的内容
          this.article.articleDetail=this.$refs.md.d_render;
        this.$axios.post("http://localhost:7000/article/create",this.article).then(res=>{
          this.$router.replace("/a1")
        })
        }
      }
    }
</script>

<style scoped>

</style>
